package com.example.app1;

import androidx.appcompat.app.AppCompatActivity;

import android.content.ComponentName;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.View;

public class MainActivity extends AppCompatActivity implements View.OnClickListener
{

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        findViewById(R.id.btn1).setOnClickListener(this);
        findViewById(R.id.btn2).setOnClickListener(this);
        findViewById(R.id.btn3).setOnClickListener(this);
    }
    @Override
    public void onClick(View v) {
        Intent intent = new Intent();

        switch (v.getId()) {
            case R.id.btn1:
                Log.d("tang", "Clicked btn");
                String phone = "10086";
                intent.setAction(Intent.ACTION_DIAL);
                Uri uri = Uri.parse("tel:" + phone);
                intent.setData(uri);
                startActivity(intent);
                break;
            case R.id.btn2:
                Log.d("tang", "Clicked btn");
                String sml = "10086";
                intent.setAction(Intent.ACTION_SENDTO);
                Uri uri2 = Uri.parse("sms:" + sml);
                intent.setData(uri2);
                startActivity(intent);
                break;
            case R.id.btn3:
                Log.d("tang", "Clicked btn");
                intent.setAction("android.intent.action.tang");
                intent.addCategory(Intent.CATEGORY_DEFAULT);
                startActivity(intent);
                break;
        }
    }
}